package com.keeson.android_cli.bean.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.keeson.android_cli.bean.UserInfo;

public class UserInfoViewModel extends ViewModel {

    private MutableLiveData<UserInfo> users;
    public LiveData<UserInfo> getUsers() {
        if (users == null) {
            users = new MutableLiveData<UserInfo>();
            loadUsers();
        }
        return users;
    }

    private void loadUsers() {
        // Do an asynchronous operation to fetch users.
        users.setValue(new UserInfo("关羽",23,"1853-05-06"));
    }
}
